import LevelBigIcon1 from '@/assets/images/LevelIcon/level_big_icon_1.png';
import LevelBigIcon2 from '@/assets/images/LevelIcon/level_big_icon_2.png';
import LevelBigIcon3 from '@/assets/images/LevelIcon/level_big_icon_3.png';
import LevelBigIcon4 from '@/assets/images/LevelIcon/level_big_icon_4.png';
import LevelBigIcon5 from '@/assets/images/LevelIcon/level_big_icon_5.png';
import LevelBigIcon6 from '@/assets/images/LevelIcon/level_big_icon_6.png';
import LevelBigIcon7 from '@/assets/images/LevelIcon/level_big_icon_7.png';
import LevelBigIcon8 from '@/assets/images/LevelIcon/level_big_icon_8.png';
import LevelBigIcon9 from '@/assets/images/LevelIcon/level_big_icon_9.png';
import LevelBigIcon10 from '@/assets/images/LevelIcon/level_big_icon_10.png';

import LevelSmallIcon1To3 from '@/assets/images/LevelIcon/level_small_icon_1_3.png';
import LevelSmallIcon4To7 from '@/assets/images/LevelIcon/level_small_icon_4_7.png';
import LevelSmallIcon8To9 from '@/assets/images/LevelIcon/level_small_icon_8_9.png';
import LevelSmallIcon10 from '@/assets/images/LevelIcon/level_small_icon_10.png';

const defaultLevelList = [{
  smallIcon: null,
  bigIcon: null,
}, {
  smallIcon: LevelSmallIcon1To3,
  bigIcon: LevelBigIcon1,
}, {
  smallIcon: LevelSmallIcon1To3,
  bigIcon: LevelBigIcon2,
}, {
  smallIcon: LevelSmallIcon1To3,
  bigIcon: LevelBigIcon3,
}, {
  smallIcon: LevelSmallIcon4To7,
  bigIcon: LevelBigIcon4,
}, {
  smallIcon: LevelSmallIcon4To7,
  bigIcon: LevelBigIcon5,
}, {
  smallIcon: LevelSmallIcon4To7,
  bigIcon: LevelBigIcon6,
}, {
  smallIcon: LevelSmallIcon4To7,
  bigIcon: LevelBigIcon7,
}, {
  smallIcon: LevelSmallIcon8To9,
  bigIcon: LevelBigIcon8,
}, {
  smallIcon: LevelSmallIcon8To9,
  bigIcon: LevelBigIcon9,
}, {
  smallIcon: LevelSmallIcon10,
  bigIcon: LevelBigIcon10,
}];

const useLevelIcon = (opt) => {
  const { levelList, level } = opt || {};
  let curLevelList = levelList || [];
  let curLevel = Number(level);
  if (!curLevelList.length) {
    curLevelList = defaultLevelList;
  }

  curLevel = Math.min(curLevel, curLevelList.length - 1);

  return {
    ...curLevelList[curLevel],
    level: curLevel,
  };
};

useLevelIcon.levelList = defaultLevelList;

export default useLevelIcon;
